import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const $cache = $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		// 提交表单列表
		formData : [
			{ label: '条码号',		name: 'spec_code', 		full:true,  type: 'textarea', required:true },
			{ label: '医院名称',		name: 'hosp_id', 		full:true,  type: 'select' },
			{ label: '用户名',		name: 'account', 		half:true, required:true  },
			{ label: '密码',			name: 'password', 		half:true,  type: 'password', required:true  },
		]
	}
	
	submit= {
		page_source: 'kf'
	}
	
	open = spec_code => {
		this.modal.open({ formRef: this.formRef })
		this.getModalSelect()
		this.formRef.setValue({ spec_code })
	}
	
	// 获取弹窗下拉
	getModalSelect = async () => {
		const { formData } = this.state
		$fn.setModalRows(formData, 'hosp_id', ()=>{
			$cache.then( async f => {
				//医院
				$fn.setRow(formData, 'hosp_id', await f.getCache({api:'hospital'}))
				// 
				this.setState({ formData })
			})
		})
	}
	
	render(){
		return FormModal.call(this,{ title: '客户变更', labelWidth:'s5', width:600, api:'specimen/changehosp'})
	}
}

export default Index